<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;



//后台模块表
class SourceModel extends Model
{
    //定义一个表名
    protected $table = 'shop_source';
    //定义主键
    protected $primaryKey = 'id';
	protected $guarded = [];

	static function getList($type){
		$data = [];
		switch($type){
			case '1':
				$res = SourceModel::where('type',1)->paginate(10);
				foreach($res as $k=>$v){
					$data[$k]['id'] = $v['id'];
					$data[$k]['title'] = $v['title'];
					$data[$k]['picname'] = "http://".$_SERVER['HTTP_HOST'].$v['picname'];
				}
				break;
			case '2':
				$res = SourceModel::where('type',2)->paginate(10);
				foreach($res as $k=>$v){
					$data[$k]['id'] = $v['id'];
					$data[$k]['title'] = $v['title'];
					$data[$k]['picname'] = "http://".$_SERVER['HTTP_HOST'].$v['picname'];
					$data[$k]['vedio'] = "http://".$_SERVER['HTTP_HOST'].$v['vedio'];
					$data[$k]['click'] = $v['click'];
				}
				break;
			case '3':
				$data = QandaModel::Select('id','question','answer')->piginate(10);
				break;

		}
		return $data;
	}

 
}
